package webServlets;

import service.AccountService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ChangeInfoServlet extends HttpServlet {
    private static final String MY_ACCOUNT = "/WEB-INF/account/EditAccountForm.jsp";
    private static final String LOGON_FORM = "/WEB-INF/account/signonForm.jsp";

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       //判断是否登录,未登录跳转到登录页面，已登录则跳转到改信息页面
        AccountService accountService = new AccountService();
        if(!accountService.isLogIn()){
            request.getRequestDispatcher(LOGON_FORM).forward(request,response);
        }else {
            request.getRequestDispatcher(MY_ACCOUNT).forward(request,response);
        }
    }
}
